﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Model.EntityModel;

namespace Project
{
    /// <summary>
    /// Interaction logic for PrintDirectionActionPart2.xaml
    /// </summary>
    public partial class PrintDirectionActionPart2 : UserControl
    {
        Person aggressor = new Person();
        Actor actorAggressor = new Actor();
        DirectAction direct = new DirectAction();
        Complaint complaint = new Complaint();
        Employee police = new Employee();

        public PrintDirectionActionPart2(long idComplaint)
        {
            InitializeComponent();
            complaint = DataAccess.ComplaintDataAccess.GetComplaintById(idComplaint);
            direct.Id = Convert.ToInt64(complaint.IdDirectAction);
            direct = DataAccess.DirectActionDataAccess.GetDirectActionById(direct.Id);
            ChargeAggressor();
            ChargePolice();
            TxtBoxReport.Text = direct.IncidentReport;
        }

        private void ChargeAggressor()
        {
            actorAggressor = DataAccess.PersonAndActorDataAccess.GetActorByTypeAndComplaintId("Agresor", complaint.Id);
            aggressor = DataAccess.PersonAndActorDataAccess.GetPersonById(actorAggressor.IdPerson);
            TxtBoxDenouncedCI.Content = aggressor.CiPassport.ToString();
            TxtBoxDenouncedName.Content = aggressor.Name;
            TxtBoxDenouncedPN.Content = aggressor.PaternalName;
            TxtBoxDenouncedMN.Content = aggressor.MaternalName;
            TxtBoxDenouncedOccupation.Content = aggressor.Ocupation;
            comboBoxDenouncedMaritalState.Content = aggressor.CivilStatus;
            TxtBoxDenouncedBornPlace.Content = aggressor.BornCity;
            TxtBoxDenouncedAddress.Content = aggressor.Address;
            TxtBoxDenouncedZone.Content = aggressor.Zone;
            TxtBoxDenouncedPhone.Content = aggressor.Phone;
            datePickerBirthDateAggressor.Content = aggressor.BirthDate.ToString();
        }

        private void ChargePolice()
        {
            police.CI = Convert.ToInt64(direct.CIEmployee);
            police = DataAccess.EmployeeDataAccess.GetEmployeeByCi(police.CI);
            TxtBoxPoliceCI.Content = police.CI;
            TxtBoxPoliceName.Content = police.Name;
            TxtBoxPolicePName.Content = police.PaternalName;
            TxtBoxPoliceMName.Content = police.MaternalName;
            TxtBoxPoliceRank.Content = police.Rank;
        }
    }
}
